package com.dhnsoft.shortLink.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhnsoft.shortLink.project.common.convention.result.Result;
import com.dhnsoft.shortLink.project.common.convention.result.Results;
import com.dhnsoft.shortLink.project.dto.req.RecycleBinRecoverDTO;
import com.dhnsoft.shortLink.project.dto.req.RecycleBinRemoveDTO;
import com.dhnsoft.shortLink.project.dto.req.RecycleBinSaveDTO;
import com.dhnsoft.shortLink.project.dto.req.ShortLinkRecycleBinPageReqDTO;
import com.dhnsoft.shortLink.project.dto.resp.ShortLinkPageRespDTO;
import com.dhnsoft.shortLink.project.service.RecycleBinService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: RecycleBinController
 * Package: com.dhnsoft.shortLink.project.controller
 * Description:
 *
 * @Author dhn
 * @Create 2024/4/1 10:46
 * @Version 1.0
 */
@RestController
@RequiredArgsConstructor
public class
RecycleBinController {

    private final RecycleBinService recycleBinService;


    /**
     * 移入短链接到回收站
     * */
    @PostMapping("/api/short-link/v1/recycle-bin/save")
    public Result<Void> saveRecycleBin(@RequestBody RecycleBinSaveDTO requestParam){
        recycleBinService.saveRecycleBin(requestParam);
        return Results.success();
    }

    /**
     * 分页查询回收站
     * */
    @GetMapping("/api/short-link/v1/recycle-bin/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageRecycle(ShortLinkRecycleBinPageReqDTO requestParam){
        IPage<ShortLinkPageRespDTO> page =  recycleBinService.pageRecycleBin(requestParam);
        return Results.success(page);
    }

    /**
     * 恢复回收站短链接
     * */
    @PostMapping("/api/short-link/v1/recycle-bin/recover")
    public Result<Void> recoverRecycleBin(@RequestBody RecycleBinRecoverDTO requestParam){
        recycleBinService.recoverRecycleBin(requestParam);
        return Results.success();
    }
    /**
     * 移除回收站短链接
     * */
    @PostMapping("/api/short-link/v1/recycle-bin/remove")
    public Result<Void> removeRecycleBin(@RequestBody RecycleBinRemoveDTO requestParam){
        recycleBinService.removeRecycleBin(requestParam);
        return Results.success();
    }

}
